<template>
    <div class="wrap">
        <a-form-item :label="item.label">
            <a-date-picker style="width: 100%;" :format="item.format || 'MM-DD'" @change="handleChange"
                :picker="item.picker"
                v-decorator="[item.dataIndex, { rules: [{ required: item.required, message: getMessage(item) }] }]" />
        </a-form-item>
    </div>
</template>
<script>
import { getMessage } from './js/js';

export default {
    name: 'FormSelect',
    props: {
        item: {
            type: Object,
            default: () => { }
        },
        formVal: {
            type: Object,
            default: () => { }
        },
        formData: {
            type: [Array, Object],
            default: () => []
        },
        form: {
            type: [Array, Object, String],
        }
    },
    methods: {
        getMessage,
        handleChange(e, s) {
            let formVal = this.form.getFieldsValue();
            let newFormV = {
                ...formVal,
                [this.item.dataIndex]: s,
            }
            this.$nextTick(() => {
                this.form.setFieldsValue({
                    ...formVal,
                    [this.item.dataIndex]: s,
                });
            });
        }
    },
}
</script>
<style lang="less" scoped>
.selectWrap {}
</style>